<!--
Copyright (c) 2019-2026, Hossein Moein
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
  notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
  notice, this list of conditions and the following disclaimer in the
  documentation and/or other materials provided with the distribution.
* Neither the name of Hossein Moein and/or the DataFrame nor the
  names of its contributors may be used to endorse or promote products
  derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL Hossein Moein BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<!DOCTYPE html>
<html>

<head>
<style>
body {
  background-image: linear-gradient(Azure, AliceBlue, GhostWhite, WhiteSmoke);
}
</style>
</head>

<body style="font-family: Georgia, serif">

  <font size="+3">&#8592;</font> <a href="https://htmlpreview.github.io/?https://github.com/hosseinmoein/DataFrame/blob/master/docs/HTML/DataFrame.html">Back to Documentations</a><BR><BR>
  
  <table border="1">

    <tr bgcolor="lightblue">
      <th>Signature</th> <th>Description</th>
    </tr>
    <tr bgcolor="Azure">
      <td>
<pre class="code_syntax" style="color:#000000;background:#ffffff00;"><span class="line_wrapper"><span style="color:#800000; font-weight:bold; ">enum</span> <span style="color:#800000; font-weight:bold; ">class</span> decompose_type <span style="color:#800080; ">:</span> <span style="color:#800000; font-weight:bold; ">unsigned</span> <span style="color:#800000; font-weight:bold; ">char</span>  <span style="color:#800080; ">{</span></span>
<span class="line_wrapper">    <span style="color:#696969; ">// Y<sub>t</sub> = Trend + Seasonal + Residual</span></span>
<span class="line_wrapper">    <span style="color:#696969; ">//</span></span>
<span class="line_wrapper">    additive <span style="color:#808030; ">=</span> <span style="color:#008c00; ">1</span><span style="color:#808030; ">,</span></span>
<span class="line_wrapper"></span>
<span class="line_wrapper">    <span style="color:#696969; ">// Y<sub>t</sub> = Trend * Seasonal * Residual</span></span>
<span class="line_wrapper">    <span style="color:#696969; ">//</span></span>
<span class="line_wrapper">    multiplicative <span style="color:#808030; ">=</span> <span style="color:#008c00; ">2</span><span style="color:#808030; ">,</span></span>
<span class="line_wrapper"><span style="color:#800080; ">}</span><span style="color:#800080; ">;</span></span>
<span class="line_wrapper"></span></pre>
      </td>
      <td>
        The additive decomposition is the most appropriate if the magnitude of the seasonal fluctuations, or the variation around the trend-cycle, does not vary with the level of the time series. When the variation in the seasonal pattern, or the variation around the trend-cycle, appears to be proportional to the level of the time series, then a multiplicative decomposition is more appropriate. Multiplicative decompositions are common with economic time series.<BR>

        An alternative to using a multiplicative decomposition is to first transform the data until the variation in the series appears to be stable over time, then use an additive decomposition. When a log transformation has been used, this is equivalent to using a multiplicative decomposition because:<BR>
        <I>Y<sub>t</sub> = T * S * R is equivalent to log(Y<sub>t</sub>) = log(T) + logt(S) + log(R)</I>
      </td>
    </tr>

  </table>

  <BR>
  
  <table border="1">

    <tr bgcolor="lightblue">
      <th>Signature</th> <th>Description</th> <th>Parameters</th>
    </tr>
    <tr bgcolor="Azure">
      <td>
<pre class="code_syntax" style="color:#000000;background:#ffffff00;"><span class="line_wrapper"><span style="color:#004a43; ">#</span><span style="color:#004a43; ">include </span><span style="color:#800000; ">&lt;</span><span style="color:#40015a; ">DataFrame/DataFrameStatsVisitors.h</span><span style="color:#800000; ">&gt;</span></span>
<span class="line_wrapper"></span>
<span class="line_wrapper"><span style="color:#800000; font-weight:bold; ">template</span><span style="color:#800080; ">&lt;</span><span style="color:#800000; font-weight:bold; ">typename</span> T<span style="color:#808030; ">,</span> <span style="color:#800000; font-weight:bold; ">typename</span> I <span style="color:#808030; ">=</span> <span style="color:#800000; font-weight:bold; ">unsigned</span> <span style="color:#800000; font-weight:bold; ">long</span><span style="color:#808030; ">,</span></span>
<span class="line_wrapper">         <span style="color:#666616; ">std</span><span style="color:#800080; ">::</span><span style="color:#603000; ">size_t</span> A <span style="color:#808030; ">=</span> <span style="color:#008c00; ">0</span><span style="color:#800080; ">&gt;</span></span>
<span class="line_wrapper"><span style="color:#800000; font-weight:bold; ">struct</span> DecomposeVisitor<span style="color:#800080; ">;</span></span>
<span class="line_wrapper"></span>
<span class="line_wrapper"><span style="color:#696969; ">// -------------------------------------</span></span>
<span class="line_wrapper"></span>
<span class="line_wrapper"><span style="color:#800000; font-weight:bold; ">template</span><span style="color:#800080; ">&lt;</span><span style="color:#800000; font-weight:bold; ">typename</span> T<span style="color:#808030; ">,</span> <span style="color:#800000; font-weight:bold; ">typename</span> I <span style="color:#808030; ">=</span> <span style="color:#800000; font-weight:bold; ">unsigned</span> <span style="color:#800000; font-weight:bold; ">long</span><span style="color:#808030; ">,</span></span>
<span class="line_wrapper">         <span style="color:#666616; ">std</span><span style="color:#800080; ">::</span><span style="color:#603000; ">size_t</span> A <span style="color:#808030; ">=</span> <span style="color:#008c00; ">0</span><span style="color:#800080; ">&gt;</span></span>
<span class="line_wrapper"><span style="color:#800000; font-weight:bold; ">using</span> decom_v <span style="color:#808030; ">=</span> DecomposeVisitor<span style="color:#800080; ">&lt;</span>T<span style="color:#808030; ">,</span> I<span style="color:#808030; ">,</span> A<span style="color:#800080; ">&gt;</span><span style="color:#800080; ">;</span></span>
<span class="line_wrapper"></span></pre>
      </td>
      <td>
        This is a "single action visitor", meaning it is passed the whole data vector in one call and you must use the single_act_visit() interface.<BR><BR>
        This visitor creates a seasonal-trend (with <a href="https://htmlpreview.github.io/?https://github.com/hosseinmoein/DataFrame/blob/master/docs/HTML/LowessVisitor.html">LOWESS</a> aka "STL") decomposition of observed time series data. This implementation is modeled after the <I>statsmodels.tsa.seasonal_decompose</I> method but substitutes a Lowess regression for a convolution in its trend estimation.<BR>
        <I>get_result()</I> returns the <B>Trend</B> vector. There are 3 get result methods: <I>get_trend(), get_seasonal(), get_residual()</I>. They return the corresponding vectors
        <I>
        <PRE>
    DecomposeVisitor(std::size_t s_period,
                     T frac,
                     T delta,
                     decompose_type type = decompose_type::additive);
        </PRE>
        </I>
<B>s_period</B>: Length of a season in untis of one observation. There must be at least two seasons in the data<BR>
<B>frac</B>: Between 0 and 1. The fraction of the data used when estimating each y-value.<BR>
<B>delta</B>: Distance within which to use linear-interpolation instead of weighted regression.<BR>
<B>type</B>: Model type. See above.<BR>
      </td>
      <td width="30%">
        <B>T</B>: Column data type.<BR>
        <B>I</B>: Index type.<BR>
        <B>A</B>: Memory alignment boundary for vectors. Default is system default alignment<BR>
      </td>
    </tr>

  </table>

<pre class="code_syntax" style="color:#000000;background:#ffffff00;"><span class="line_wrapper"><span style="color:#800000; font-weight:bold; ">static</span> <span style="color:#800000; font-weight:bold; ">void</span> test_DecomposeVisitor<span style="color:#808030; ">(</span><span style="color:#808030; ">)</span>  <span style="color:#800080; ">{</span></span>
<span class="line_wrapper"></span>
<span class="line_wrapper">    <span style="color:#666616; ">std</span><span style="color:#800080; ">::</span><span style="color:#603000; ">cout</span> <span style="color:#808030; ">&lt;</span><span style="color:#808030; ">&lt;</span> <span style="color:#800000; ">"</span><span style="color:#0f69ff; ">\n</span><span style="color:#0000e6; ">Testing DecomposeVisitor{  } ...</span><span style="color:#800000; ">"</span> <span style="color:#808030; ">&lt;</span><span style="color:#808030; ">&lt;</span> <span style="color:#666616; ">std</span><span style="color:#800080; ">::</span><span style="color:#603000; ">endl</span><span style="color:#800080; ">;</span></span>
<span class="line_wrapper"></span>
<span class="line_wrapper">    StlVecType<span style="color:#800080; ">&lt;</span><span style="color:#800000; font-weight:bold; ">double</span><span style="color:#800080; ">&gt;</span>         y_vec <span style="color:#808030; ">=</span></span>
<span class="line_wrapper">        <span style="color:#800080; ">{</span> <span style="color:#008000; ">131.157</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">131.367</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">132.215</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">132.725</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">132.648</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">130.585</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">130.701</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.631</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.168</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.554</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.467</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.670</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">128.397</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.014</span><span style="color:#808030; ">,</span></span>
<span class="line_wrapper">          <span style="color:#008000; ">129.496</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">131.067</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">130.219</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">128.947</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.602</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">128.118</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">127.356</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">127.231</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">127.154</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">128.417</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.091</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.082</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">128.937</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">130.441</span><span style="color:#808030; ">,</span></span>
<span class="line_wrapper">          <span style="color:#008000; ">129.371</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.294</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.381</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.564</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.708</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">130.701</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">130.663</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">130.113</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">130.046</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">130.393</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">128.026</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.204</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">130.530</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.499</span><span style="color:#808030; ">,</span></span>
<span class="line_wrapper">          <span style="color:#008000; ">129.266</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.357</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">130.431</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">131.810</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">131.761</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">131.675</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">130.923</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">131.694</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">133.005</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">133.323</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">134.152</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">138.702</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">137.719</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">135.492</span><span style="color:#808030; ">,</span></span>
<span class="line_wrapper">          <span style="color:#008000; ">133.622</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">134.518</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">132.725</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">131.839</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">138.548</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">140.996</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">143.734</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">150.693</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">151.108</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">149.423</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">150.416</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">149.491</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">151.273</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">150.299</span><span style="color:#808030; ">,</span></span>
<span class="line_wrapper">          <span style="color:#008000; ">146.783</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">147.173</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">146.939</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">147.290</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">145.946</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">142.624</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">138.027</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">136.118</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.650</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">126.767</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">130.809</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">125.550</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">130.732</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">126.183</span><span style="color:#808030; ">,</span></span>
<span class="line_wrapper">          <span style="color:#008000; ">124.410</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">114.748</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">121.527</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">114.904</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">100.138</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">105.144</span><span style="color:#808030; ">,</span></span>
<span class="line_wrapper">        <span style="color:#800080; ">}</span><span style="color:#800080; ">;</span></span>
<span class="line_wrapper">    MyDataFrame                df<span style="color:#800080; ">;</span></span>
<span class="line_wrapper"></span>
<span class="line_wrapper">    df<span style="color:#808030; ">.</span>load_data<span style="color:#808030; ">(</span>MyDataFrame<span style="color:#800080; ">::</span>gen_sequence_index<span style="color:#808030; ">(</span><span style="color:#008c00; ">0</span><span style="color:#808030; ">,</span> y_vec<span style="color:#808030; ">.</span>size<span style="color:#808030; ">(</span><span style="color:#808030; ">)</span><span style="color:#808030; ">,</span> <span style="color:#008c00; ">1</span><span style="color:#808030; ">)</span><span style="color:#808030; ">,</span> <span style="color:#666616; ">std</span><span style="color:#800080; ">::</span>make_pair<span style="color:#808030; ">(</span><span style="color:#800000; ">"</span><span style="color:#0000e6; ">IBM_closes</span><span style="color:#800000; ">"</span><span style="color:#808030; ">,</span> y_vec<span style="color:#808030; ">)</span><span style="color:#808030; ">)</span><span style="color:#800080; ">;</span></span>
<span class="line_wrapper"></span>
<span class="line_wrapper">    DecomposeVisitor<span style="color:#800080; ">&lt;</span><span style="color:#800000; font-weight:bold; ">double</span><span style="color:#808030; ">,</span> <span style="color:#800000; font-weight:bold; ">unsigned</span> <span style="color:#800000; font-weight:bold; ">long</span><span style="color:#808030; ">,</span> <span style="color:#008c00; ">64</span><span style="color:#800080; ">&gt;</span>    d_v <span style="color:#808030; ">(</span><span style="color:#008c00; ">7</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.6</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.01</span><span style="color:#808030; ">)</span><span style="color:#800080; ">;</span></span>
<span class="line_wrapper"></span>
<span class="line_wrapper">    df<span style="color:#808030; ">.</span>single_act_visit<span style="color:#800080; ">&lt;</span><span style="color:#800000; font-weight:bold; ">double</span><span style="color:#800080; ">&gt;</span><span style="color:#808030; ">(</span><span style="color:#800000; ">"</span><span style="color:#0000e6; ">IBM_closes</span><span style="color:#800000; ">"</span><span style="color:#808030; ">,</span> d_v<span style="color:#808030; ">)</span><span style="color:#800080; ">;</span></span>
<span class="line_wrapper"></span>
<span class="line_wrapper">    <span style="color:#800000; font-weight:bold; ">auto</span>    actual_trends <span style="color:#808030; ">=</span> StlVecType<span style="color:#800080; ">&lt;</span><span style="color:#800000; font-weight:bold; ">double</span><span style="color:#800080; ">&gt;</span></span>
<span class="line_wrapper">        <span style="color:#800080; ">{</span> <span style="color:#008000; ">130.613</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">130.55</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">130.489</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">130.43</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">130.372</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">130.317</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">130.263</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">130.211</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">130.161</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">130.111</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">130.064</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">130.017</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.972</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.928</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.885</span><span style="color:#808030; ">,</span></span>
<span class="line_wrapper">          <span style="color:#008000; ">129.842</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.801</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.76</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.72</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.681</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.642</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.603</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.564</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.526</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.49</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.458</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.435</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.459</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.496</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.546</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.61</span><span style="color:#808030; ">,</span></span>
<span class="line_wrapper">          <span style="color:#008000; ">129.688</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.78</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.885</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">130.002</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">130.129</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">130.267</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">130.414</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">130.568</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">130.73</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">130.898</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">131.071</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">131.248</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">131.429</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">131.613</span><span style="color:#808030; ">,</span></span>
<span class="line_wrapper">          <span style="color:#008000; ">131.801</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">131.994</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">132.193</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">132.4</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">132.618</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">132.847</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">133.089</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">133.343</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">133.594</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">133.814</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">133.958</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">133.982</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">133.867</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">133.633</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">133.329</span><span style="color:#808030; ">,</span></span>
<span class="line_wrapper">          <span style="color:#008000; ">133.013</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">132.715</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">132.449</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">132.214</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">131.88</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">131.594</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">131.336</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">131.094</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">130.862</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">130.636</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">130.412</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">130.191</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.97</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.749</span><span style="color:#808030; ">,</span></span>
<span class="line_wrapper">          <span style="color:#008000; ">129.527</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.305</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">129.082</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">128.858</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">128.633</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">128.406</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">128.178</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">127.949</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">127.717</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">127.484</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">127.249</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">127.012</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">126.773</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">126.531</span><span style="color:#808030; ">,</span></span>
<span class="line_wrapper">          <span style="color:#008000; ">126.288</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">126.043</span></span>
<span class="line_wrapper">        <span style="color:#800080; ">}</span><span style="color:#800080; ">;</span></span>
<span class="line_wrapper"></span>
<span class="line_wrapper">    <span style="color:#800000; font-weight:bold; ">for</span> <span style="color:#808030; ">(</span><span style="color:#603000; ">size_t</span> idx <span style="color:#808030; ">=</span> <span style="color:#008c00; ">0</span><span style="color:#800080; ">;</span> idx <span style="color:#808030; ">&lt;</span> actual_trends<span style="color:#808030; ">.</span>size<span style="color:#808030; ">(</span><span style="color:#808030; ">)</span><span style="color:#800080; ">;</span> <span style="color:#808030; ">+</span><span style="color:#808030; ">+</span>idx<span style="color:#808030; ">)</span></span>
<span class="line_wrapper">        assert<span style="color:#808030; ">(</span><span style="color:#603000; ">fabs</span><span style="color:#808030; ">(</span>d_v<span style="color:#808030; ">.</span>get_trend<span style="color:#808030; ">(</span><span style="color:#808030; ">)</span><span style="color:#808030; ">[</span>idx<span style="color:#808030; ">]</span> <span style="color:#808030; ">-</span> actual_trends<span style="color:#808030; ">[</span>idx<span style="color:#808030; ">]</span><span style="color:#808030; ">)</span> <span style="color:#808030; ">&lt;</span> <span style="color:#008000; ">0.001</span><span style="color:#808030; ">)</span><span style="color:#800080; ">;</span></span>
<span class="line_wrapper"></span>
<span class="line_wrapper">    <span style="color:#800000; font-weight:bold; ">auto</span>    actual_seasonals <span style="color:#808030; ">=</span> StlVecType<span style="color:#800080; ">&lt;</span><span style="color:#800000; font-weight:bold; ">double</span><span style="color:#800080; ">&gt;</span></span>
<span class="line_wrapper">        <span style="color:#800080; ">{</span> <span style="color:#008000; ">0.499135</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.362488</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.0226401</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.138991</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.774313</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.152695</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.951993</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.499135</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.362488</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.0226401</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.138991</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.774313</span><span style="color:#808030; ">,</span></span>
<span class="line_wrapper">          <span style="color:#808030; ">-</span><span style="color:#008000; ">0.152695</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.951993</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.499135</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.362488</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.0226401</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.138991</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.774313</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.152695</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.951993</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.499135</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.362488</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.0226401</span><span style="color:#808030; ">,</span></span>
<span class="line_wrapper">          <span style="color:#808030; ">-</span><span style="color:#008000; ">0.138991</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.774313</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.152695</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.951993</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.499135</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.362488</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.0226401</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.138991</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.774313</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.152695</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.951993</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.499135</span><span style="color:#808030; ">,</span></span>
<span class="line_wrapper">          <span style="color:#808030; ">-</span><span style="color:#008000; ">0.362488</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.0226401</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.138991</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.774313</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.152695</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.951993</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.499135</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.362488</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.0226401</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.138991</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.774313</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.152695</span><span style="color:#808030; ">,</span></span>
<span class="line_wrapper">          <span style="color:#008000; ">0.951993</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.499135</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.362488</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.0226401</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.138991</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.774313</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.152695</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.951993</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.499135</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.362488</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.0226401</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.138991</span><span style="color:#808030; ">,</span></span>
<span class="line_wrapper">          <span style="color:#808030; ">-</span><span style="color:#008000; ">0.774313</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.152695</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.951993</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.499135</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.362488</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.0226401</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.138991</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.774313</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.152695</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.951993</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.499135</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.362488</span><span style="color:#808030; ">,</span></span>
<span class="line_wrapper">          <span style="color:#808030; ">-</span><span style="color:#008000; ">0.0226401</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.138991</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.774313</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.152695</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.951993</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.499135</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.362488</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.0226401</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.138991</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.774313</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.152695</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.951993</span><span style="color:#808030; ">,</span></span>
<span class="line_wrapper">          <span style="color:#008000; ">0.499135</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.362488</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.0226401</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.138991</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.774313</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.152695</span></span>
<span class="line_wrapper">        <span style="color:#800080; ">}</span><span style="color:#800080; ">;</span></span>
<span class="line_wrapper"></span>
<span class="line_wrapper">    <span style="color:#800000; font-weight:bold; ">for</span> <span style="color:#808030; ">(</span><span style="color:#603000; ">size_t</span> idx <span style="color:#808030; ">=</span> <span style="color:#008c00; ">0</span><span style="color:#800080; ">;</span> idx <span style="color:#808030; ">&lt;</span> actual_seasonals<span style="color:#808030; ">.</span>size<span style="color:#808030; ">(</span><span style="color:#808030; ">)</span><span style="color:#800080; ">;</span> <span style="color:#808030; ">+</span><span style="color:#808030; ">+</span>idx<span style="color:#808030; ">)</span></span>
<span class="line_wrapper">        assert<span style="color:#808030; ">(</span><span style="color:#603000; ">fabs</span><span style="color:#808030; ">(</span>d_v<span style="color:#808030; ">.</span>get_seasonal<span style="color:#808030; ">(</span><span style="color:#808030; ">)</span><span style="color:#808030; ">[</span>idx<span style="color:#808030; ">]</span> <span style="color:#808030; ">-</span> actual_seasonals<span style="color:#808030; ">[</span>idx<span style="color:#808030; ">]</span><span style="color:#808030; ">)</span> <span style="color:#808030; ">&lt;</span> <span style="color:#008000; ">0.00001</span><span style="color:#808030; ">)</span><span style="color:#800080; ">;</span></span>
<span class="line_wrapper"></span>
<span class="line_wrapper">    <span style="color:#800000; font-weight:bold; ">auto</span>    actual_residuals <span style="color:#808030; ">=</span> StlVecType<span style="color:#800080; ">&lt;</span><span style="color:#800000; font-weight:bold; ">double</span><span style="color:#800080; ">&gt;</span></span>
<span class="line_wrapper">        <span style="color:#800080; ">{</span> <span style="color:#008000; ">0.0450645</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">1.17948</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">1.74866</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">2.43421</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">3.04989</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.420796</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.514129</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">1.07918</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.630027</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.534809</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.457752</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.427013</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">1.42233</span><span style="color:#808030; ">,</span></span>
<span class="line_wrapper">          <span style="color:#808030; ">-</span><span style="color:#008000; ">1.86582</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.887751</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">1.58716</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.440736</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.674248</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.656095</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">1.41002</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">3.2376</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">2.87093</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">2.04782</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">1.08684</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.260342</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.397977</span><span style="color:#808030; ">,</span></span>
<span class="line_wrapper">          <span style="color:#808030; ">-</span><span style="color:#008000; ">0.345524</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.0298508</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.623855</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.110697</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.206247</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.014974</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.702412</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.968872</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.290624</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.515527</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.141332</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.0017837</span><span style="color:#808030; ">,</span></span>
<span class="line_wrapper">          <span style="color:#808030; ">-</span><span style="color:#008000; ">2.40348</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.751754</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.215182</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">2.52399</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">2.48155</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">1.7098</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">1.15976</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.147774</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.541487</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.36517</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">2.4292</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">1.42281</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.520609</span><span style="color:#808030; ">,</span></span>
<span class="line_wrapper">          <span style="color:#008000; ">0.256637</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.94848</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">5.88205</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">4.05781</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">0.58219</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.858726</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">1.01365</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">0.88524</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">1.35148</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">6.30971</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">8.4335</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">10.3326</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">17.98</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">19.5905</span><span style="color:#808030; ">,</span></span>
<span class="line_wrapper">          <span style="color:#008000; ">17.8516</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">19.2189</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">19.171</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">20.5634</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">18.7112</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">15.8714</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">17.3448</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">16.992</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">17.6804</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">17.1932</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">13.4718</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">7.99313</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">6.76106</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">1.3799</span><span style="color:#808030; ">,</span></span>
<span class="line_wrapper">          <span style="color:#808030; ">-</span><span style="color:#008000; ">1.61643</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">2.7699</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">1.62422</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">3.16745</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">2.25312</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">3.33817</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">11.9014</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">5.22295</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">11.4883</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">25.3757</span><span style="color:#808030; ">,</span> <span style="color:#808030; ">-</span><span style="color:#008000; ">20.7463</span></span>
<span class="line_wrapper">        <span style="color:#800080; ">}</span><span style="color:#800080; ">;</span></span>
<span class="line_wrapper"></span>
<span class="line_wrapper">    <span style="color:#800000; font-weight:bold; ">for</span> <span style="color:#808030; ">(</span><span style="color:#603000; ">size_t</span> idx <span style="color:#808030; ">=</span> <span style="color:#008c00; ">0</span><span style="color:#800080; ">;</span> idx <span style="color:#808030; ">&lt;</span> actual_residuals<span style="color:#808030; ">.</span>size<span style="color:#808030; ">(</span><span style="color:#808030; ">)</span><span style="color:#800080; ">;</span> <span style="color:#808030; ">+</span><span style="color:#808030; ">+</span>idx<span style="color:#808030; ">)</span></span>
<span class="line_wrapper">        assert<span style="color:#808030; ">(</span><span style="color:#603000; ">fabs</span><span style="color:#808030; ">(</span>d_v<span style="color:#808030; ">.</span>get_residual<span style="color:#808030; ">(</span><span style="color:#808030; ">)</span><span style="color:#808030; ">[</span>idx<span style="color:#808030; ">]</span> <span style="color:#808030; ">-</span> actual_residuals<span style="color:#808030; ">[</span>idx<span style="color:#808030; ">]</span><span style="color:#808030; ">)</span> <span style="color:#808030; ">&lt;</span> <span style="color:#008000; ">0.0001</span><span style="color:#808030; ">)</span><span style="color:#800080; ">;</span></span>
<span class="line_wrapper"><span style="color:#800080; ">}</span></span>
<span class="line_wrapper"></span>
<span class="line_wrapper"><span style="color:#696969; ">// -----------------------------------------------------------------------------</span></span>
<span class="line_wrapper"></span>
<span class="line_wrapper"><span style="color:#800000; font-weight:bold; ">static</span> <span style="color:#800000; font-weight:bold; ">void</span> test_IBM_data<span style="color:#808030; ">(</span><span style="color:#808030; ">)</span>  <span style="color:#800080; ">{</span></span>
<span class="line_wrapper"></span>
<span class="line_wrapper">    <span style="color:#666616; ">std</span><span style="color:#800080; ">::</span><span style="color:#603000; ">cout</span> <span style="color:#808030; ">&lt;</span><span style="color:#808030; ">&lt;</span> <span style="color:#800000; ">"</span><span style="color:#0f69ff; ">\n</span><span style="color:#0000e6; ">Testing IBM_data(  ) ...</span><span style="color:#800000; ">"</span> <span style="color:#808030; ">&lt;</span><span style="color:#808030; ">&lt;</span> <span style="color:#666616; ">std</span><span style="color:#800080; ">::</span><span style="color:#603000; ">endl</span><span style="color:#800080; ">;</span></span>
<span class="line_wrapper"></span>
<span class="line_wrapper">    <span style="color:#800000; font-weight:bold; ">typedef</span> StdDataFrame<span style="color:#800080; ">&lt;</span><span style="color:#666616; ">std</span><span style="color:#800080; ">::</span><span style="color:#603000; ">string</span><span style="color:#800080; ">&gt;</span> StrDataFrame<span style="color:#800080; ">;</span></span>
<span class="line_wrapper"></span>
<span class="line_wrapper">    StrDataFrame    df<span style="color:#800080; ">;</span></span>
<span class="line_wrapper"></span>
<span class="line_wrapper">    df<span style="color:#808030; ">.</span><span style="color:#603000; ">read</span><span style="color:#808030; ">(</span><span style="color:#800000; ">"</span><span style="color:#0000e6; ">IBM.csv</span><span style="color:#800000; ">"</span><span style="color:#808030; ">,</span> io_format<span style="color:#800080; ">::</span>csv2<span style="color:#808030; ">)</span><span style="color:#800080; ">;</span></span>
<span class="line_wrapper"></span>
<span class="line_wrapper">    DecomposeVisitor<span style="color:#800080; ">&lt;</span><span style="color:#800000; font-weight:bold; ">double</span><span style="color:#808030; ">,</span> <span style="color:#666616; ">std</span><span style="color:#800080; ">::</span><span style="color:#603000; ">string</span><span style="color:#800080; ">&gt;</span> d_v<span style="color:#808030; ">(</span><span style="color:#008c00; ">178</span><span style="color:#808030; ">,</span> <span style="color:#008000; ">2.0</span> <span style="color:#808030; ">/</span> <span style="color:#008000; ">3.0</span><span style="color:#808030; ">,</span> <span style="color:#008c00; ">0</span><span style="color:#808030; ">,</span> decompose_type<span style="color:#800080; ">::</span>multiplicative<span style="color:#808030; ">)</span><span style="color:#800080; ">;</span></span>
<span class="line_wrapper">    <span style="color:#696969; ">// decompose_type::additive);</span></span>
<span class="line_wrapper"></span>
<span class="line_wrapper">    df<span style="color:#808030; ">.</span>single_act_visit<span style="color:#800080; ">&lt;</span><span style="color:#800000; font-weight:bold; ">double</span><span style="color:#800080; ">&gt;</span><span style="color:#808030; ">(</span><span style="color:#800000; ">"</span><span style="color:#0000e6; ">IBM_Adj_Close</span><span style="color:#800000; ">"</span><span style="color:#808030; ">,</span> d_v<span style="color:#808030; ">)</span><span style="color:#800080; ">;</span></span>
<span class="line_wrapper"></span>
<span class="line_wrapper">    <span style="color:#800000; font-weight:bold; ">const</span> <span style="color:#800000; font-weight:bold; ">auto</span>  <span style="color:#808030; ">&amp;</span>ibm_closes <span style="color:#808030; ">=</span> df<span style="color:#808030; ">.</span>get_column<span style="color:#800080; ">&lt;</span><span style="color:#800000; font-weight:bold; ">double</span><span style="color:#800080; ">&gt;</span><span style="color:#808030; ">(</span><span style="color:#800000; ">"</span><span style="color:#0000e6; ">IBM_Adj_Close</span><span style="color:#800000; ">"</span><span style="color:#808030; ">)</span><span style="color:#800080; ">;</span></span>
<span class="line_wrapper"></span>
<span class="line_wrapper">    <span style="color:#800000; font-weight:bold; ">for</span> <span style="color:#808030; ">(</span><span style="color:#666616; ">std</span><span style="color:#800080; ">::</span><span style="color:#603000; ">size_t</span> i <span style="color:#808030; ">=</span> <span style="color:#008c00; ">0</span><span style="color:#800080; ">;</span> i <span style="color:#808030; ">&lt;</span> ibm_closes<span style="color:#808030; ">.</span>size<span style="color:#808030; ">(</span><span style="color:#808030; ">)</span><span style="color:#800080; ">;</span> <span style="color:#808030; ">+</span><span style="color:#808030; ">+</span>i<span style="color:#808030; ">)</span></span>
<span class="line_wrapper">        <span style="color:#666616; ">std</span><span style="color:#800080; ">::</span><span style="color:#603000; ">cout</span> <span style="color:#808030; ">&lt;</span><span style="color:#808030; ">&lt;</span> ibm_closes<span style="color:#808030; ">[</span>i<span style="color:#808030; ">]</span> <span style="color:#808030; ">&lt;</span><span style="color:#808030; ">&lt;</span> <span style="color:#800000; ">"</span><span style="color:#0000e6; ">,</span><span style="color:#800000; ">"</span></span>
<span class="line_wrapper">                  <span style="color:#808030; ">&lt;</span><span style="color:#808030; ">&lt;</span> d_v<span style="color:#808030; ">.</span>get_trend<span style="color:#808030; ">(</span><span style="color:#808030; ">)</span><span style="color:#808030; ">[</span>i<span style="color:#808030; ">]</span> <span style="color:#808030; ">&lt;</span><span style="color:#808030; ">&lt;</span> <span style="color:#800000; ">"</span><span style="color:#0000e6; ">,</span><span style="color:#800000; ">"</span></span>
<span class="line_wrapper">                  <span style="color:#808030; ">&lt;</span><span style="color:#808030; ">&lt;</span> d_v<span style="color:#808030; ">.</span>get_seasonal<span style="color:#808030; ">(</span><span style="color:#808030; ">)</span><span style="color:#808030; ">[</span>i<span style="color:#808030; ">]</span> <span style="color:#808030; ">&lt;</span><span style="color:#808030; ">&lt;</span> <span style="color:#800000; ">"</span><span style="color:#0000e6; ">,</span><span style="color:#800000; ">"</span></span>
<span class="line_wrapper">                  <span style="color:#808030; ">&lt;</span><span style="color:#808030; ">&lt;</span> d_v<span style="color:#808030; ">.</span>get_residual<span style="color:#808030; ">(</span><span style="color:#808030; ">)</span><span style="color:#808030; ">[</span>i<span style="color:#808030; ">]</span> <span style="color:#808030; ">&lt;</span><span style="color:#808030; ">&lt;</span> <span style="color:#666616; ">std</span><span style="color:#800080; ">::</span><span style="color:#603000; ">endl</span><span style="color:#800080; ">;</span></span>
<span class="line_wrapper"><span style="color:#800080; ">}</span></span>
<span class="line_wrapper"></span></pre>

  <BR><img src="https://github.com/hosseinmoein/DataFrame/blob/master/docs/LionLookingUp.jpg?raw=true" alt="C++ DataFrame"
       width="200" height="200" style="float:right"/>

</body>
</html>

<!--
Local Variables:
mode:HTML
tab-width:4
c-basic-offset:4
End:
-->
